<fieldset style="border:none;">
	<legend></legend>
	<div >
		<input type="hidden" name="user.id" value="#(user.id??)" />
		<div class="layui-form-item">
			<div class="layui-inline col-12 col-sm-24"> 
				<label class="layui-form-label col-6 col-sm-6">用户名</label>
				<div class="layui-input-inline col-18 col-sm-16">
					<select id="userID" name="user.userID" lay-filter="changeID" #(bEdit ? 'disabled':'')>
							#@option(userList,"id","userName",user.userID??,true)
					</select>
				</div>
			</div>
			#if(bEdit)
			<div class="layui-inline col-12 col-sm-24">
				<label class="layui-form-label col-6 col-sm-6">接口密码</label>
				<div class="layui-input-inline col-18 col-sm-16">
					<input type="text" name="password" value="#(password)" readonly lay-verify="" autocomplete="off" placeholder="" class="layui-input">
				</div>
			</div>
			#end
		</div>
		<div class="layui-form-item">
			<div class="layui-inline col-12 col-sm-24"> 
				<label class="layui-form-label col-6 col-sm-6">到期日期</label>
				<div class="layui-input-inline col-18 col-sm-16">
					<input type="text" id="dqrq" name="user.dqrq" value="#(user.dqrq??)" lay-verify="date" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline col-12 col-sm-24">
				<label class="layui-form-label col-6 col-sm-6">IP限制</label>
				<div class="layui-input-inline col-18 col-sm-16">
					<input type="text" name="user.limitIP" value="#(user.limitIP??)" lay-verify="" autocomplete="off" placeholder="请输入IP限制" class="layui-input">
				</div>
			</div>
		</div>

		<div class="layui-form-item"> 
			<label class="layui-form-label col-3 col-sm-6">状态</label> 
			<div class="layui-input-inline col-21 col-sm-16"> 
				<input type="hidden" id="userstate" name="user.state" value="#(user.state??1)">
				<input type="checkbox" #(user.state??"1"=="1" ? 'checked':'') lay-skin="switch" lay-filter="switchState" lay-text="启用|禁用">
			</div>
		</div>
		<div class="layui-form-item">
			<div style="text-align: center;">
				<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
				#if(bEdit)
				<a href="xpApi/right_ui?userID=#(user.userID??)" class="layui-btn layui-btn-primary">设置接口</a>
				#end
				<a href="xpApi/user" class="layui-btn layui-btn-primary">返回</a>
			</div>
		</div>
	</div>
	<script>
		
			layui.use(['form', 'laydate'], function(){
				var form = layui.form
				,layer = layui.layer
				,laydate = layui.laydate;
				laydate.render({
				    elem: '#dqrq' //指定元素
			  	});


				//自定义验证规则
				form.verify({
					userName: function(value){
						if(value.length < 5){
							return '用户名至少得5个字符啊';
						}
					},
				});

				//监听指定开关
// 				form.on('select(changeID)', function(data){
// 					if(data.value!="#(departmentID)")
// 					{
// 						$("#role").css("display","none");
// 						$("input[name='role']").removeAttr("checked");
// 						form.render('checkbox');
// 					}
// 					else
// 					{
// 						if($("#type").val()=="2")
// 							$("#role").css("display","block");
// 						else
// 						{
// 							$("#role").css("display","none");
// 							$("input[name='role']").removeAttr("checked");
// 						}
// 						form.render('checkbox');
// 					}
// 				});
				
				//监听指定开关
// 				form.on('select(changetype)', function(data){
// 					if(data.value=="1")
// 					{
// 						$("#role").css("display","none");
// 						$("input[name='role']").removeAttr("checked");
// 						form.render('checkbox');
// 					}
// 					else
// 					{
// 						if($("#departmentID").val()=="#(departmentID)")
// 							$("#role").css("display","block");
// 						else
// 						{
// 							$("#role").css("display","none");
// 							$("input[name='role']").removeAttr("checked");
// 						}
// 						form.render('checkbox');
// 					}
// 				});
				
				//监听指定开关
				form.on('switch(switchState)', function(data){
					$("#userstate").val(this.checked ? '1' : '0');
				});

				//监听提交
				form.on('submit(demo1)', function(data){
						//layer.alert(JSON.stringify(data.field), { title: '最终的提交信息' });
						//return false;
					$("#userID").removeAttr("disabled");
				});
			});
			
		$(function(){		
			#if(msg)
				xpsoft.msg('#(msg)');
			#end
		});			
		
	</script>
</fieldset>
